package kuang.jmm;

import java.util.concurrent.TimeUnit;

public class VolatileDemo1 {

    private static int num = 1;

    public static void main(String[] args) throws InterruptedException {

        new Thread(() -> {
            while(num == 1){
                //由于当前线程一直拿不到num最新的值
                //所以一直在循环
            }
        }).start();

        //保证前面线程已经开启
        TimeUnit.SECONDS.sleep(3);
        num = 0;
    }
}
